ABC245 C - Choose Elements
提出
code: python
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
# 全探索は計算量オーバー
for i in range(n-1):
if (abs(ai - ai+1) > k and abs(ai - bi+1) > k and abs(bi - bi+1) > k and abs(bi - ai+1) > k): print('No')
exit()
print('Yes')
解答
code: python
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(1, n):
print("Yes")
else:
print("No")
テーマ
メモ
提出
code: python
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
# X = (a,b) どちらかを選択
ta = []
tb = []
for i in range(n-1):
ta.append((True if abs(ai-ai+1) <= k else False, True if abs(ai-bi+1) <= k else False)) tb.append((True if abs(bi-bi+1) <= k else False, True if abs(bi-ai+1) <= k else False)) for i in range(n-2):
continue
continue
continue
continue
print("No")
exit()
print("Yes")